package com.erp.purchase.receipts.controller;

import com.erp.common.annotation.Anonymous;
import com.erp.common.core.controller.BaseController;
import com.erp.common.core.domain.AjaxResult;
import com.erp.common.core.page.TableDataInfo;
import com.erp.purchase.receipts.domain.ErpPurchaseReceipts;
import com.erp.purchase.receipts.service.ErpPurchaseReceiptsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * --- 天道酬勤 ---
 *
 * @author ZhangYuqi
 * @date 2025/9/5
 * @desc
 */
@RestController
@RequestMapping("/purchase/receipts")
public class ErpPurchaseReceiptsController extends BaseController {
    @Autowired
    private ErpPurchaseReceiptsService erpPurchaseReceiptsService;
    @GetMapping("/list")
    public TableDataInfo listReceipts(ErpPurchaseReceipts erpPurchaseReceipts) {
        startPage();
        List<ErpPurchaseReceipts> list = erpPurchaseReceiptsService.selectPurchaseReceiptsList(erpPurchaseReceipts);
        System.out.println(list);
        System.out.println(getDataTable(list));
        return getDataTable(list);
    }
    @GetMapping("/get/{inboundNo}")
    public ErpPurchaseReceipts getReceipts(@PathVariable("inboundNo") String inboundNo) {

        return erpPurchaseReceiptsService.selectPurchaseReceiptsById(inboundNo);
    }
    @GetMapping("/updateView/{inboundNo}")
    public AjaxResult updateViewReceipts(@PathVariable("inboundNo") String inboundNo) {
        erpPurchaseReceiptsService.updateViewPurchaseReceiptsView(inboundNo);
        return AjaxResult.success();
    }
    @PutMapping("/update")
    public AjaxResult updateReceipts(@RequestBody ErpPurchaseReceipts erpPurchaseReceipts) {
        return toAjax(erpPurchaseReceiptsService.updatePurchaseReceipts(erpPurchaseReceipts));
    }
}
